using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public abstract class IPlayer : IAttrPlayer
{
    public bool defend = false;
    public bool defendsucess = false;
    public float Charged = 0;
    public AudioSource audioSource;
    public AudioClip clip;
    protected void Init()
    {
        audioSource = transform.GetComponent<AudioSource>();
        if(audioSource.volume!=0)
        audioSource.volume = GameFacade.Instance.volume+0.5f;
        mAttr = GameFacade.Instance.attrFactory.GetAttr(AttrType.Player1);
        MaxHP = mAttr.BornHp;
        mName = mAttr.Name;
        Attacknumber = mAttr.BornAttack;
        AttackRange = mAttr.AttackRange;
        mSystem = new PlayerFSMSystem();
        mAnimator = transform.GetComponent<Animator>();
        rb = transform.GetComponent<Rigidbody>();
        IplayerFSM Playeridle = new PlayerIdel(mSystem, this);
        Playeridle.AddTransition(e_Playerstate.Idle, e_PlayerstateId.Idle);
        Playeridle.AddTransition(e_Playerstate.Attack, e_PlayerstateId.Attack);
        Playeridle.AddTransition(e_Playerstate.Chase, e_PlayerstateId.Chase);
        IplayerFSM PlayerMove = new PlayerMove(mSystem, this);
        PlayerMove.AddTransition(e_Playerstate.Attack, e_PlayerstateId.Attack);
        PlayerMove.AddTransition(e_Playerstate.Idle, e_PlayerstateId.Idle);
        PlayerMove.AddTransition(e_Playerstate.Chase, e_PlayerstateId.Chase);
        IplayerFSM PlayerAttack = new PlayerAttack(mSystem, this);
        PlayerAttack.AddTransition(e_Playerstate.Chase, e_PlayerstateId.Chase);
        PlayerAttack.AddTransition(e_Playerstate.Idle, e_PlayerstateId.Idle);
        PlayerAttack.AddTransition(e_Playerstate.Attack, e_PlayerstateId.Attack);
        mSystem.AddState(Playeridle);
        mSystem.AddState(PlayerAttack);
        mSystem.AddState(PlayerMove);
    }
    public abstract void GetHit(int damage);
    public abstract void InIdle();
    public abstract void UpdateIdle();
    public abstract void LeaveIdle();
    public abstract void InChase();
    public abstract void UpdateChase();
    public abstract void LeaveChase();
    public abstract void InAttack();
    public abstract void UpdateAttack();
    public abstract void LeaveAttack();
    public void UpdateDo()
    {
       
        mSystem.CurrentState.Update();
        
    }
    public abstract void Attack(int id);
    
}
